#ifndef _2_73
#define _2_73
#include<climits>

/**
 * reference :
 *    http://lambda.cool/wiki/doku.php?id=answers:csapp:homework-2.73
 */

/* Addition that saturates to INT_MAX or INT_MIN*/
int saturating_add(int x, int y){
      int result = x + y;
      int pos_over = !(x & INT_MIN) && !(y & INT_MIN) && (sum & INT_MIN);
      int neg_over = (x & INT_MIN) && (y & INT_MIN) && !(sum & INT_MIN);

      (!pos_over || (result = INT_MAX)) && (!neg_over || (result = INT_MIN));

      return result;
}

#endif // _2_73

